package com.epam.giorgadze.task3.factory;

import com.epam.giorgadze.task3.entity.AirCompany;
import com.epam.giorgadze.task3.logic.AirCompanyLogic;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * User: Luka
 * Date: 16.02.14
 * Time: 21:27
 */
public class AirCompanyFactory {

    static List<String> listOfManufacturers = new ArrayList<String>();

    static {
        listOfManufacturers.add("Boeing");
        listOfManufacturers.add("Boeing");
        listOfManufacturers.add("Boeing");
        listOfManufacturers.add("Airbus");
        listOfManufacturers.add("Airbus");
        listOfManufacturers.add("SAAB");
        listOfManufacturers.add("SAAB");
    }

    static List<String> listOfPlaneModelsNames = new ArrayList<String>();

    static {
        listOfPlaneModelsNames.add("Boeing 737");
        listOfPlaneModelsNames.add("Boeing 747");
        listOfPlaneModelsNames.add("Boeing 787");
        listOfPlaneModelsNames.add("Airbus A340");
        listOfPlaneModelsNames.add("Airbus A350");
        listOfPlaneModelsNames.add("Saab 340");
        listOfPlaneModelsNames.add("Saab 2000");
    }

    static List<String> listOfAddresses = new ArrayList<String>();

    static {
        listOfAddresses.add("100 N Riverside Plaza, Chicago, IL 60606, USA");
        listOfAddresses.add("100 N Riverside Plaza, Chicago, IL 60606, USA");
        listOfAddresses.add("100 N Riverside Plaza, Chicago, IL 60606, USA");
        listOfAddresses.add("Kreetslag 10,21129 Hamburg, Germany");
        listOfAddresses.add("Kreetslag 10,21129 Hamburg, Germany");
        listOfAddresses.add("Gustavslundsvägen 42, Bromma, Sweden");
        listOfAddresses.add("Gustavslundsvägen 42, Bromma, Sweden");
    }

    static List<String> listOfEmails = new ArrayList<String>();

    static {
        listOfEmails.add("boeing@boeing.com");
        listOfEmails.add("boeing@boeing.com");
        listOfEmails.add("boeing@boeing.com");
        listOfEmails.add("airbus@airbus.com");
        listOfEmails.add("airbus@airbus.com");
        listOfEmails.add("saab@saab.com");
        listOfEmails.add("saab@sabb.com");
    }

    public static AirCompany createRandomAirCompany(int numberOfPlanes, String ID) {
        AirCompany airCompany = new AirCompany(ID);
        Random rand = new Random();
        for (int i = 0; i < numberOfPlanes; i++) {
            int k = rand.nextInt(listOfEmails.size());
            AirCompanyLogic.addPlane(airCompany, PlaneFactory.Planes.values()[(new Random().nextInt(PlaneFactory.Planes.values().length))],
                    listOfPlaneModelsNames.get(k), listOfManufacturers.get(k), listOfEmails.get(k), listOfAddresses.get(k));
        }
        return airCompany;
    }
}
